#!/usr/bin/env python
# -*- coding:utf-8 -*-
"""
@file:PluginApi.py
@time:2017/7/21 0021 9:39
"""
from ...src.plugins.CpuPlugin import CpuPlugin
from ...src.plugins.MotherboardPlugin import MotherboardPlugin
from ...lib import log
from ...lib.response import BaseResponse

def get_server_info():
    response = BaseResponse()
    try:
        server_info = {}
        cpuObj = CpuPlugin()
        boardObj = MotherboardPlugin()

        collect_hostname = boardObj.os_hostname()
        hostname = collect_hostname
        server_info['os_platform'] = boardObj.os_platform()
        server_info['os_version'] = boardObj.os_version()

        board_info = boardObj.execute()
        server_info.update(board_info)

        cpu_info = cpuObj.execute()
        server_info.update(cpu_info)
        response.data = server_info
        response.status = True
    except Exception as e:
        response.message = str(e)
    return response
